﻿using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Phone.Shell;

namespace Com.PhilChuang.Pmvp.Model.Services.Impl
{
	public class TransientAppStateService : ITransientAppStateService
	{
		private IDictionary<String, Object> myState
		{ get { return PhoneApplicationService.Current.State; } }

		public TransientAppStateService ()
		{
		}

		#region Implementation of IEnumerable
		public IEnumerator<KeyValuePair<string, object>> GetEnumerator ()
		{ return myState.GetEnumerator (); }

		IEnumerator IEnumerable.GetEnumerator ()
		{ return GetEnumerator (); }
		#endregion

		#region Implementation of ICollection<KeyValuePair<string,object>>
		public void Add (KeyValuePair<string, object> item)
		{ myState.Add (item); }

		public void Clear ()
		{ myState.Clear (); }

		public bool Contains (KeyValuePair<string, object> item)
		{ return myState.Contains (item); }

		public void CopyTo (KeyValuePair<string, object>[] array, int arrayIndex)
		{ myState.CopyTo (array, arrayIndex); }

		public bool Remove (KeyValuePair<string, object> item)
		{ return myState.Remove (item);}

		public int Count
		{ get { return myState.Count; } }

		public bool IsReadOnly
		{ get { return myState.IsReadOnly; } }
		#endregion

		#region Implementation of IDictionary<string,object>
		public bool ContainsKey (string key)
		{ return myState.ContainsKey (key); }

		public void Add (string key, object value)
		{ myState.Add (key, value); }

		public bool Remove (string key)
		{ return myState.Remove (key); }

		public bool TryGetValue (string key, out object value)
		{ return myState.TryGetValue (key, out value); }

		public object this [string key]
		{
			get { return myState[key]; }
			set { myState[key] = value; }
		}

		public ICollection<string> Keys
		{ get { return myState.Keys; } }

		public ICollection<object> Values
		{ get { return myState.Values; } }
		#endregion
	}
}
